package org.je.image;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.image.BufferedImage;
import javax.swing.JFrame;

public class ImageShow extends JFrame implements KeyListener
{
	private static final long	serialVersionUID	= 1L;

	private BufferedImage		img;

	public ImageShow(BufferedImage img) {
		this.setUndecorated(true);
		this.setBackground(Color.white);
		this.img = img;
		int w = img.getWidth();
		int h = img.getHeight();
		this.setBounds((1366 - w) / 2, (768 - h) / 2, w, h);
		this.addKeyListener(this);
		this.setVisible(true);
	}

	public void paint(Graphics g) {
		g.clearRect(0, 0, img.getWidth(), img.getHeight());
		g.drawImage(img, 0, 0, null);
	}

	public void update(Graphics g) {
		paint(g);
	}

	public void keyTyped(KeyEvent e) {}

	public void keyPressed(KeyEvent e) {}

	public void keyReleased(KeyEvent e) {
		if (e.getKeyCode() == 27)
			System.exit(0);
	}
}
